home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / telecomm / sticpsrc.lzh / DOC / ENVIRON.ARC / ENVIRON.TXT < prev   
Text File  |  1989-03-05  |  7KB  |  183 lines

  1. Environment variables in NET
  2.  
  3. By Rob Janssen, PE1CHL.
  4.  
  5. NET has been enhanced with support for variables.  This means you 
  6. can set variables to some (string) value, and use these values in 
  7. commands.  This is especially useful in the configuration files.
  8. Also, some variable names are reserved to hold the names of the 
  9. different directories and files referenced by NET, so that you 
  10. can now locate these wherever you like.
  11.  
  12.  
  13. setenv command
  14.  
  15. Variables are set using the "setenv" command in NET.  The 
  16. possible uses are:
  17.  
  18. setenv
  19.      setenv without parameters displays the currently defined 
  20.      variables, in alphabetic order, with their values.
  21.  
  22. setenv name value
  23.      the variable "name" is given "value" as it's value.  the 
  24.      previous value of "name" is lost, and the variable is 
  25.      created automatically if it did not yet exist.
  26.  
  27. setenv name
  28.      the variable "name" loses it's value and will not be 
  29.      displayed by "setenv" any more.  this is different from 
  30.      assigning an empty value to the variable, which can be done 
  31.      using: setenv name "".
  32.  
  33. setenv name=value
  34.      this form is allowed as an alternative to the second case.
  35.  
  36. The name of a variable can contain letters, digits and the 
  37. underscore character, and it is always converted to UPPER CASE 
  38. before it is stored or referenced.
  39.  
  40. After a variable has been assigned using setenv (or other means, 
  41. see below), it can be used in 2 basically different ways:
  42.  
  43. 1. Implicitly used by NET
  44.  
  45. When the name of the variable is one of the reserved names, NET 
  46. will automatically use it.  It is generally unwise to set these 
  47. reserved variables to empty or nonsense values, as this may cause 
  48. problems in the operation of NET.
  49.  
  50. The reserved names are:
  51.  
  52. NETSTART       Initialization file
  53. NETUSERS       Authorized FTP users and passwords
  54. NETHOSTS       Network host table
  55. NETFINGER      Finger file path
  56. NETMAILS       Incoming mail
  57. NETMAILQ       Outgoing mail spool
  58. NETROUTEQ      Queue for router
  59. NETALIAS       The alias file
  60.  
  61. And, on the Atari ST:
  62. TMPDIR         Temp files directory
  63.  
  64. So, by using the command "setenv NETHOSTS d:\hosts.net", you 
  65. change the name of the hosts file to "d:\hosts.net", and if this 
  66. is on a RAM-disk the lookup of hostnames will be somewhat faster.
  67.  
  68.  
  69. 2. Explicit use in a NET command
  70.  
  71. A variable can be used in every NET command instead of (parts of) 
  72. a command name or a parameter.  Variables are referenced using 
  73. the $ sign followed by their name, as in:
  74.  
  75.      attach netrom $CALLSIGN
  76.  
  77. In this case, $CALLSIGN is replaced by the contents of the 
  78. variable CALLSIGN before the command is executed.  A variable can 
  79. also contain part of a parameter, as in:
  80.  
  81.      attach asy 3f8 4 ax25 ax0 512 256 4800 $CALLSIGN-2
  82.  
  83. In this case, the -2 ssid will be appended to the callsign stored 
  84. in the variable CALLSIGN.
  85.  
  86. When the text to be appended could be mistaken for part of the 
  87. variable name, the name can be enclosed in braces: ${VARNAME}000.
  88.  
  89. There also exist some more advanced ways of referencing 
  90. variables, to make it possible to provide defaults for undefined 
  91. ones:
  92.  
  93. ${NAME-default}
  94.      This will return the value of the variable NAME if it is 
  95.      defined, or "default" if NAME is undefined.
  96.  
  97. ${NAME=default}
  98.      Acts the same as the privious case, but it additionally sets 
  99.      the variable NAME to value "default" if it did not exist.
  100.  
  101. ${NAME?text}
  102.      When NAME is defined, returns it's value.  If not, it prints 
  103.      "text" and the commandline is not executed.  When "text" is 
  104.      not present, "undefined variable" is printed.
  105.  
  106. ${NAME+text}
  107.      When NAME is defined, returns "text".  When NAME is not 
  108.      defined, returns an empty string.
  109.  
  110.  
  111.  
  112. Initial setting of variables
  113.  
  114. The value of variables at the time NET is started is determined 
  115. as follows:
  116.  
  117. 1.   When NET is started, the variable table is empty.  It first 
  118.      inserts de default values of the "reserved" variables into 
  119.      the table.  The values are the pathnames that used to be 
  120.      fixed in earlier releases, e.g.:
  121.           NETMAILQ=/spool/mqueue/
  122.  
  123. 2.   The variables in the environment passed by the operating 
  124.      system are added to the table, possibly replacing the 
  125.      defaults.  This means a variable can be given an initial 
  126.      value by putting it in the environment of the shell that 
  127.      starts NET (in MS-DOS: using a SET command in COMMAND.COM)
  128.  
  129. 3.   Parameters to the NET program of the form "name=value" are 
  130.      parsed as "setenv" commands.  This continues from left to 
  131.      right until a parameter is encountered that does not contain 
  132.      an "=" sign, or all parameters have been parsed.
  133.  
  134. 4.   NET performs internal initializations, that possibly use the 
  135.      variables defined up to this moment.  Thereafter it prints 
  136.      the banner.
  137.  
  138. 5.   When there are no more parameters, the file whose name is in 
  139.      the variable NETSTART is executed as a command file.  
  140.      Normally this will be AUTOEXEC.NET.
  141.      If there are parameters left at this point, they are 
  142.      examined from left to right.  If they don't contain an "=" 
  143.      sign they are assumed to be filenames and executed as a 
  144.      command file, if they do contain an "=" they are parsed as 
  145.      "setenv" commands.
  146.  
  147. 6.   The prompt is printed and NET starts operating 
  148.      interactively.
  149.  
  150. Example of a NET commandlines:
  151.  
  152.      net callsign=pe1chl autoexec.st2 running=1
  153.  
  154. This starts NET with variable CALLSIGN set to value "pe1chl", 
  155. then NET reads the startupfile "autoexec.st2" and after this file 
  156. has been completely executed, variable RUNNING is set to 1.
  157.  
  158.      net callsign=pe1chl
  159.  
  160. Same as above, but the default startup file defined in NETSTART 
  161. is executed with variable CALLSIGN set to "pe1chl".
  162. Note that in this case it is still possible to run a nonstandard 
  163. startupfile if you define it's name in the environment of the 
  164. shell.  For MS-DOS this can be done by typing
  165.  
  166.      set netstart=autoexec.2
  167.  
  168. from the COMMAND.COM prompt.
  169.  
  170.  
  171.  
  172. Environment passed to sub-shells
  173.  
  174. When NET starts a sub-shell (using the command "shell" or "!"), 
  175. it passes the values of all variables as an environment to this 
  176. sub-shell.  As it reads in the environment itself during startup, 
  177. this passed environment at least contains the required variables 
  178. for every executed shell.
  179. But as it also contains the variables that you can set yourself, 
  180. this feature can be used to define the environment for a mailer 
  181. run from NET, using setenv commands in the startup file.
  182.  
  183.